﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Sapro_Project
{
    public partial class ListTurm : PhoneApplicationPage
    {
        List<Grid> nomes = new List<Grid>();
        TextBlock novo;
        Button exc;
        Button edit;
        public ListTurm()
        {
            InitializeComponent();
        }

        private void ContentPanel_Loaded(object sender, RoutedEventArgs e)
        {
            foreach (Escola esc in Fachada.ObterFachada().BuscaEscola()){
                novo = new TextBlock();
                exc = new Button();
                edit = new Button();
                Grid ret = new Grid();
                novo.MouseLeftButtonDown += delegate(object ob, MouseButtonEventArgs c) {
                    ret.Background = new SolidColorBrush(Colors.Gray);
                    
                };
                novo.MouseLeftButtonUp += delegate(object ob, MouseButtonEventArgs c)
                {
                    ret.Background = new SolidColorBrush(Colors.Transparent);
                    MessageBox.Show("Eu");
                };
                novo.MouseMove += delegate(object ob, MouseEventArgs c)
                {
                    ret.Background = new SolidColorBrush(Colors.Transparent);
                };
                novo.MouseLeave += delegate(object ob, MouseEventArgs c)
                {
                    ret.Background = new SolidColorBrush(Colors.Transparent);
                };
                Thickness tk0 = new Thickness();
                tk0.Top = 18;
                tk0.Left = 18;
                novo.Margin = tk0;
                novo.FontSize = 30;
                novo.Foreground = new SolidColorBrush(Colors.Black);
                novo.Text = "" + esc.Nome;
                edit.Content = "ed";
                edit.Width = 75;
                Thickness tk = new Thickness();
                tk.Left = 254;
                tk.Top = 6;
                edit.Margin = tk;
                exc.Content = "ex";
                exc.CommandParameter = 1;
                exc.Width = 75;
                Thickness tk2 = new Thickness();
                tk2.Left = 354;
                tk2.Top = 6;
                exc.Margin = tk2;
                String nome = esc.Nome;
                exc.Click += delegate(object s, RoutedEventArgs ev)
                {
                    MessageBox.Show(nome);
                };
                ret.Width = 430;
                ret.Children.Add(novo);
                ret.Children.Add(edit);
                ret.Children.Add(exc);
                nomes.Add(ret);
            }
            //for (int i = 0; i < 10; i++)
            //{
                
            //}
            list_turmas.ItemsSource = nomes;
        }

        private void cad_turmas_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
